<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
</head>


<body>

<img src="../img/2.jpg" alt="">

<script>
    const element = document.querySelector('img');
    console.log(element.src)
    element.src = './../img/1.jpg'
    element.title = '想出去玩'
</script>
</body>
</html>